/**
 * ...
 * @author HTML5
 */
 
function DisplayList() 
{
	this.children 	= new Array();
	this.updateList = new Array();
	this.boost		= null;
}


DisplayList.prototype.children 		= null;
DisplayList.prototype.updateList 	= null;
DisplayList.prototype.boost 		= null;


DisplayList.prototype.updateDynamics = function()
{
	if( this.boost == null )
		return;
		
	var child = null;
		
	while( this.updateList.length > 0 )
	{
		child = this.updateList[0];
		this.boost.removeChild( child );
		this.boost.addChild( child );
		this.updateList.shift();
	}
};

DisplayList.prototype.getVisibleChildrenIn = function( p_x, p_y, p_width, p_height )
{
	this.updateDynamics();
	var tab = ( this.boost == null ) ? this.children : this.boost.getVisibleChildrenIn( p_x, p_y, p_width, p_height );
	return tab;	
};

DisplayList.prototype.addChild = function( p_child )
{
	p_child.displayList = this;
	this.children.push( p_child );
	
	if( this.boost != null )
	{
		this.boost.addChild( p_child );
	}
};

DisplayList.prototype.removeChild = function( p_child )
{
	var index = this.children.indexOf( p_child );
	if (index > -1)
	{
		this.children.splice( index, 1 );
	}
	
	if( this.boost != null )
	{
		this.boost.removeChild( p_child );
	}
};

DisplayList.prototype.removeChildren = function()
{	
	if( this.boost != null )
	{
		this.boost.clean();
	}
	
	this.children = new Array();
};

DisplayList.prototype.destroy = function()
{
	this.children = null;
	if( this.boost != null )
	{
		this.boost.destroy();
		this.boost = null;
	}
};
